import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    const msg = ref('Hello')
    const doubleCount = computed(() => count.value * 2)
    function increment() {
      count.value++
    }
    function updateMsg() {
      msg.value += '~'
    }

    return { count, doubleCount, increment, updateMsg, msg }
  },
  {
    // unistorage: true, // 存储此文件全部数据
    unistorage: {
      paths: ['count'], // 只存储 count 数据
    },
  }
)
